#include<iostream>
using namespace std;
struct stu{
    bool show=false;
    string name;
    string id;
};


int main(){
    int N;
    //freopen("in.txt","r",stdin);
    scanf("%d",&N);
    stu hastable[101];
    string name,id;int score;
    for(int i=1;i<=N;i++){
        cin>>name>>id>>score;
        hastable[score].name=name;
        hastable[score].id=id;
        hastable[score].show=true;
    }
    int lower,upper;
    scanf("%d %d",&lower,&upper);
    bool flag=false;
    for(int i=upper;i>=lower;i--){
        if(hastable[i].show==false)continue;
        cout<<hastable[i].name<<" "<<hastable[i].id<<endl;
        flag=true;
    }
    if(flag==false){
        printf("NONE\n");
    }
    return 0;

}
